package com.jsj.controller;

import com.jsj.pojo.Device;
import com.jsj.pojo.Laboratory;
import com.jsj.service.LabDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LabDeviceController {

    @Autowired
    LabDeviceService labDeviceService;

    //查询laboratory 和device的映射关系，labdevice表
    //查询该实验室所有的设备
    @RequestMapping("queryDeviceIdByLabId")
    @ResponseBody
    public List<Device> queryDeviceIdByLabId(int labId){

        List<Device> deviceList = labDeviceService.queryDeviceIdByLabId(labId);
        return deviceList;

    }

    //给实验室增加设备（增加映射关系）
    @RequestMapping("addDeviceToLab")
    @ResponseBody
    public List addDeviceToLab(int labId,int deviceId){

        List list = labDeviceService.addDeviceToLab(labId, deviceId);
        return list;
    }

    //删除某设备
    @RequestMapping("delLabDeviceById")
    @ResponseBody
    public Boolean delLabDeviceById(int labId,int deviceId){

        Boolean aBoolean = labDeviceService.delLabDeviceById(labId,deviceId);
        return aBoolean;

    }

    @RequestMapping("queryLabDeviceByName")
    @ResponseBody
    public List<Device> queryLabDeviceByName(String deviceName ){

        List<Device> deviceList = labDeviceService.queryLabDeviceByName(deviceName);

        return deviceList;
    }


}
